package top.wardyan.wdev.dbassist.service.impl;

import top.wardyan.wdev.dbassist.service.IYPGetIDService;

public class YPGetIDServiceImpl implements IYPGetIDService{

	private static final String NAME = "{call yp_getid(?,?,?,?)}";
	
	@Override
	public Integer yp_getid(Integer pID, String pTableName, Integer pQty) {
		return (Integer) com.jfinal.plugin.activerecord.Db.execute(new com.jfinal.plugin.activerecord.ICallback(){
			@Override
			public Integer call(java.sql.Connection conn) throws java.sql.SQLException {
				java.sql.CallableStatement proc = conn.prepareCall(NAME);
				proc.setInt(1,pID);
				proc.setString(2,pTableName);
				proc.setInt(3,pQty);
				proc.registerOutParameter(4,java.sql.Types.INTEGER);

				proc.execute();

				return proc.getInt(4);
			}
		});
	}
}
